import http from '@/utils/http'
import {
    AUTH_USER_PROFILE,
    AUTH_USER_LIST,
    AUTH_USER_LOGIN,
    AUTH_USER_LOGOUT,
    AUTH_USER_ADD,
    AUTH_USER_UPDATE,
    AUTH_USER_DELETE,
    AUTH_USER_LOGIN_CAPTCHA
} from '@/config/api'
import {
    IAuthUser,
    IAuthUserDeleteParameter,
    IAuthUserEditParameter,
    IAuthUserListParameter,
    IAuthUserLoginParameter,
    IAuthUserToken
} from '@/types/auth/user'
import { ICaptcha, IPageList } from '@/types/global'

export function authUserProfile() {
    return http.get<IAuthUser>(AUTH_USER_PROFILE)
}

export function authUserLogin(params: IAuthUserLoginParameter) {
    return http.post<IAuthUserToken>(AUTH_USER_LOGIN, params)
}

export function authUserLogout() {
    return http.post(AUTH_USER_LOGOUT)
}

export function authUserList(params: IAuthUserListParameter) {
    return http.get<IPageList<IAuthUser[]>>(AUTH_USER_LIST, params)
}

export function authUserAdd(parameter: IAuthUserEditParameter) {
    return http.post(AUTH_USER_ADD, parameter)
}

export function authUserUpdate(parameter: IAuthUserEditParameter) {
    return http.post(AUTH_USER_UPDATE, parameter)
}

export function authUserDelete(parameter: IAuthUserDeleteParameter) {
    return http.post(AUTH_USER_DELETE, parameter)
}

// 登录验证码
export function authUserLoginCaptcha() {
    return http.get<ICaptcha>(AUTH_USER_LOGIN_CAPTCHA)
}
